package com.hugoo.form.xo;

import com.hugoo.core.util.TL;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Lovelock.Chan
 */
public class XSql extends XVar {

    @Override
    public String getParentDbl() {
       return this.getxHandle().getDbl();
    }

    public enum SqlTpe {

        DDL, PROC, SQL
    }
    //操作语句类型【DDL:操作语句、PROC:存储过程、SQL：查询语句】
    private String tpe;
    private String var;
    //操作语句模板
    private String tpl;
    private List<XFlt> xFltList = new ArrayList();
    private XHandle xHandle;

    public SqlTpe getTpes() {
        if (TL.isEmpty(tpe)) {
            return SqlTpe.DDL;
        } else if ("SQL".equalsIgnoreCase(tpe)) {
            return SqlTpe.SQL;
        } else if ("PROC".equalsIgnoreCase(tpe)) {
            return SqlTpe.PROC;
        }
        return SqlTpe.DDL;
    }

    public String getTpe() {
        return tpe;
    }

    public void setTpe(String tpe) {
        this.tpe = tpe;
    }

    public void addXFlt(XFlt xflt) {
        xflt.setxSql(this);
        xFltList.add(xflt);
    }

    public XHandle getxHandle() {
        return xHandle;
    }

    public void setxHandle(XHandle xHandle) {
        this.xHandle = xHandle;
    }

    public List<XFlt> getxFltList() {
        return xFltList;
    }

    public void setxFltList(List<XFlt> xFltList) {
        this.xFltList = xFltList;
    }

    public String getVar() {
        return var;
    }

    public void setVar(String var) {
        if (var != null) {//设置为大写模式
            this.var = var.toUpperCase();
        }
    }

    public String getTpl() {
        return tpl;
    }

    public void setTpl(String tpl) {
        if (tpl != null) {//设置为大写模式
            this.tpl = tpl.toUpperCase();
        }
    }
}
